﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public class Player : Hands
    {
        internal int numberOfCards;     
        private string move;
        private bool canSplit;
        private DecisionEngine decisionEngine;

        public int NumberOfCards
        {
            get { return numberOfCards; }
            set { numberOfCards = value; }
        }

        public string Move
        {
            get { return move; }
            set { move = value; }
        }

        public bool CanSplit
        {
            get { return canSplit; }
            set { canSplit = value; }
        }

        public Player()
        {
            hands = new List<Card>();
        }

        public void MakeTheRightMove(int dealerUpCard)
        {
            try
            {
                if ((this.numberOfCards == 2) && (this.canSplit) && (this.Total != 10))
                {
                     makeDecision(dealerUpCard, Decision.split);
                }
                else if (this.AceCount > 0)
                {
                     makeDecision(dealerUpCard, Decision.Ace);
                }
                else
                {
                     makeDecision(dealerUpCard, Decision.Standard);
                }
            }
            catch
            {
                MessageBox.Show("ERROR IN NEXT PLAYER RIGHT-MOVE CALCULATIONS");
                this.move = "ERROR";
            }
        }
        
        private void makeDecision(int dealerUpCard, Decision decision )
        {
            decisionEngine = new DecisionEngine(this, dealerUpCard, decision);
            this.move = decisionEngine.DecisionAction.ToString();
        }

    }

   
}
